<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8"%>
<%@ include file="/include/taglibs.jsp"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  <title>无标题文档</title>
  <%@ include file="/include/jquery.libs.jsp"%>
</head>
<body style="background: #f0f9fd;">
<div class="formbody">
  <div class="formtitle"><span>模块基本信息</span></div>
  <form id="ff_field_edit" method="post">
    <ul class="forminfo">
      <li><label><fmt:message key="field.code" />:</label><input name="code" type="text"
                                                                 style="width: 345px; height: 32px;" class="easyui-textbox"
                                                                 data-options="required:true" /><i>字段编码不能超过50个字符</i>
      </li>
      <li><label><fmt:message key="field.name" />:</label><input name="name" type="text"
                                                                 style="width: 345px; height: 32px;" class="easyui-textbox"
                                                                 data-options="required:true" /><i>名称不能超过50个字符</i>
      </li>
      <li><label><fmt:message key="column.order" />:</label><input name="order" type="text"
                                                                   style="width: 345px; height: 32px;" class="easyui-numberbox"
                                                                   data-options="required:false" /><i>数据库排序的字段</i>
      </li>
    </ul>
  </form>
  <div style="text-align: center; padding: 5px">
    <a href="javascript:void(0)" class="easyui-linkbutton" onclick="submitForm()">保存数据</a>
    <a href="javascript:void(0)" class="easyui-linkbutton" onclick="clearForm()">清除数据</a>
  </div>
</div>
<script type="text/javascript">

  $(function(){
    fillForm();
  });

  function fillForm(){
    $.ajax({
      type:'GET',
      url:'${ctx}/${frameworkPath}/field/view/${param.id}',
      success:function(data){
        $('#ff_field_edit').form('load', data.rows);
      },
      error: function(XmlHttpRequest, textStatus, errorThrown){
        $.messager.alert('<fmt:message key="message.title" />','错误：'+XmlHttpRequest.status, 'error');;
      }
    });
  }

  function submitForm() {
    $('#ff_field_edit').ajaxSubmit({
      type: 'post',
      url: "${ctx}/${frameworkPath}/field/edit/${param.id}",
      success: function(data){
        window.top.closeDialog();
        if(data.success){
          window.parent.refreshDatagrid('dg_field');
          $.messager.alert('<fmt:message key="message.title" />', '<fmt:message key="message.save.successful" />', 'info');
        }
        else{
          $.messager.alert('<fmt:message key="message.title" />', '保存失败:'+data.error, 'error');
        }
      },
      error: function(XmlHttpRequest, textStatus, errorThrown){
        window.top.closeDialog();
        $.messager.alert('<fmt:message key="message.title" />','错误：'+XmlHttpRequest.status, 'error');
      }
    });
  };
</script>
</body>
</html>